#pragma once

#if !defined _BACKDOOR_PROXYSTUB_H_
#define _BACKDOOR_PROXYSTUB_H_

#include "Network.h"
#include "Pool.h"

namespace hxc
{

struct ParamPacket
{
    short InstanceID;
    short ProcID;
    BYTE ParamCount;
    struct _Params
    {
        USHORT cb;
        BYTE Param[1];
    }Params;
};

template<class T, class EventClass>
class CProxy :
            public IUnknown,
            public T
{
public:
    BOOL BeginInvoke()
    {
        this->T::BufferLock.Enter();
        if (this->T::Buffer->second == nullptr)
        {
            CHAR *pBuffer = nullptr;
            SI->dp->GetFreeBuffer(&pBuffer, 1);
            this->T::Buffer->first = pBuffer;
            this->T::Buffer->second = pBuffer;
        }
    }

    BOOL EndInvoke()
    {
        this->T::BufferLock.Leave();
    }
    BOOL InitInterface(CTCPSocket *pSocket);
    STDMETHOD(QueryInterface)(REFIID riid,  void **ppvObject)
    {
        return E_NOTIMPL;
    }

    STDMETHOD_(ULONG, AddRef)(void)
    {
        return E_NOTIMPL;
    }

    STDMETHOD_(ULONG, Release)(void)
    {
        return E_NOTIMPL;
    }
protected:
    DECLARE_EVENT(OnReturn, EventClass, BOOL);
};

class CStub
{
public:
};

class CProxyIShellFolder// : public IShellFolder
{
public:
    static REFIID riidInterface;
    Critical_Section BufferLock;
    std::pair<void*, CHAR*> Buffer;
};

};//namespace hxc

#endif//if !defined _BACKDOOR_PROXYSTUB_H_